﻿//写cookie
function setCookie(name, value) {
    var Days = 30;
    var exp = new Date();
    exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
    document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
}

//读取cookies 
function getCookie(name) {
    var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");

    if (arr = document.cookie.match(reg))

        return unescape(arr[2]);
    else
        return null;
}

//删除cookies 
function delCookie(name) {
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval = getCookie(name);
    if (cval != null)
        document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
} 
////设置cookie
function setCookieProjectObj(obj){
    setCookie("name", obj.Name);
    setCookie("budget", obj.Budget);
    setCookie("edesign", obj.EDesign);
    setCookie("echarge", obj.Echarge);
    setCookie("finish", obj.FinishTime);
    setCookie("input", obj.InputTime);
    setCookie("value", obj.Value);
    setCookie("realbudge", obj.RealBudge);
    setCookie("mdesign", obj.MDesign);
    setCookie("mcharge", obj.MCharge);
    setCookie("userarea", obj.UserArea);
    setCookie("id", obj.Id);
    setCookie("status", obj.Status);
    setCookie("chargeman", obj.ChargeMan);
    setCookie("caps_n", obj.Caps);
    setCookie("protype_n", obj.ProType);
    setCookie("lessbudget", obj.LessBudget);
    setCookie("NewID", obj.NewID);
    var c = obj.Caps;
    if (c == 0) { setCookie("caps", '费用化'); } else if (c == 1) { "caps", '资本化' } else if (c==2){ "caps", '费用化和资本化'}
    var d = obj.ProType;
    if (d == 0) { setCookie("protype", '技改类'); } else if (d == 1) { "protype", '新开发类' } else if (d == 2) { "protype", '现场支持无产生实际费用类' }
}